/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__binary_search.c                                 */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/11 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../../src/module/oracle/config.h"
#include <oracle/comm/ora_charset.h>
#include <apmtest_comm.h>

extern int __binary_search(unsigned int ui_key);

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

/**
 * 正确测试
 */
static void __case1(void)
{
    CU_ASSERT_NOT_EQUAL(__binary_search(1), -1);
}

/**
 * 异常测试
 */
static void __case2(void)
{
    CU_ASSERT_EQUAL(__binary_search(3000), -1);
}

int add_suite__binary_search(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __binary_search()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
